package com.woorigil.social.domain.category;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.stereotype.Repository;

import com.woorigil.social.domain.CouponSqlMapDaoSupport;

@Repository
public class CategoryDao extends CouponSqlMapDaoSupport<Category, Integer> {
	public static final String NAMESPACE = "Category";

	@Override
	public String getNamespace() {
		return NAMESPACE;
	}

	@SuppressWarnings("unchecked")
	public List<Category> search(CategoryCondition condition) {
		return getSqlMapClientTemplate().queryForList(getStatementName(NAMESPACE, "search"), condition);
	}

	@SuppressWarnings("unchecked")
	public List<Category> searchAll() {
		return getSqlMapClientTemplate().queryForList(getStatementName(NAMESPACE, "searchAll"));
	}
	
	@SuppressWarnings("unchecked")
	public List<Category> selectByKeyword(String keyword) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("keyword", keyword);
		return getSqlMapClientTemplate().queryForList(getStatementName(NAMESPACE, "selectByKeyword"), params);
	}

	public List<Category> selectListByLevel(int levelNo) {
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("levelNo", levelNo);
		return getSqlMapClientTemplate().queryForList(getStatementName(NAMESPACE, "selectListByLevel"), params);
	}
}